<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopMemberCard extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('shop_member_card',['engine'=>'InnoDB'])->setComment('商城-会员卡表');
        $table->addColumn(Column::string('name',100)->setNullable()->setComment('名称'));
        $table->addColumn(Column::decimal('money',10,2)->setDefault(50)->setComment('需支付金额'));
        $table->addColumn(Column::integer('wash_number')->setDefault(0)->setComment('可清洗次数'));
        $table->addColumn(Column::tinyInteger('validity')->setDefault(1)->setComment('有效期(月)'));
        $table->addColumn(Column::text('content')->setNullable()->setComment('权益说明'));
        $table->addColumn(Column::integer('sort')->setDefault(0)->setComment('排序'));
        $table->addColumn(Column::tinyInteger('status')->setDefault(1)->setComment('状态(0:禁用,1:启用)'));
        $table->addColumn(Column::tinyInteger('is_deleted')->setDefault(0)->setComment('删除(1:删除,0:未删)'));
        $table->addTimestamps('create_at');
        $table->create();
    }
}
